import request from '@/utils/request'

const userApi = {
  Login: '/app/login/password', // 用户密码登录
  // Logout: '/auth/logout',
  loginCode: '/app/login/auth/code',
  SendSms: '/app/send/auth/code', // 发送验证码
  getServeToken: '/app/login/client', // 获取客户端token
  checkAuthCode: '/app/check/auth/code', // 校验验证码
  getWechatAppid: '/app/get/wechat/jsapi/appid', // 获取品牌的appid
  addRequestParam: '/app/add/request/param', // 缓存请求参数
}

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login (parameter) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: Object.assign(parameter,{loginType: 1})
  })
}

export function getSmsCaptcha (parameter) {
  return request({
    url: userApi.SendSms,
    method: 'post',
    data: parameter
  })
}

// 获取客户端token
export function getServeToken(parameter){
  return request({
    url: userApi.getServeToken,
    method: 'post',
    data: Object.assign(parameter,{loginType: 1})
  })
}

export function loginCode (parameter) {
  return request({
    url: userApi.loginCode,
    method: 'post',
    data: Object.assign(parameter,{loginType: 1})
  })
}

export function checkAuthCode(parameter){
  return request({
    url: userApi.checkAuthCode,
    method: 'post',
    data: parameter,
  })
}

export function getWechatAppid(parameter){
  return request({
    url: userApi.getWechatAppid,
    method: 'post',
    data: parameter,
  })
}

export function addRequestParam(parameter){
  return request({
    url: userApi.addRequestParam,
    method: 'post',
    data: parameter,
  })
}